<template>
  <div class="app-container">
    <div class="filter-container">
      <el-form ref="dataForm" size="mini" :model="listQuery" label-position="right" label-width="auto">
        <div class="lineBox">
          <el-form-item label="档号" prop="dh">
            <el-input v-model="listQuery.dh" size="mini" placeholder="" style="width: 120px" />
          </el-form-item>
        </div>
        <div class="lineBox">
          <el-form-item label="全宗号：" prop="qzh">
            <el-input v-model="listQuery.qzh" size="mini" placeholder="" style="width: 120px" />
          </el-form-item>
        </div>

        <div class="lineBox" style="width: 190px">
          <el-form-item label="密级：" prop="mj">
            <el-input v-model="listQuery.mj" size="mini" placeholder="" style="width: 120px" />
          </el-form-item>
        </div>

        <div class="lineBox">
          <el-form-item label="期限：" prop="bgqx" style="width: 190px">
            <el-input v-model="listQuery.bgqx" size="mini" placeholder="" style="width: 120px" />
          </el-form-item>
        </div>

        <div class="lineBox">
          <el-form-item label="类别号：" prop="lbh">
            <el-input v-model="listQuery.lbh" size="mini" placeholder="" style="width: 120px" />
          </el-form-item>
        </div>

        <div class="lineBox">
          <el-form-item label="时间：" prop="sj">
            <el-input v-model="listQuery.sj" size="mini" placeholder="" style="width: 120px" />
          </el-form-item>
        </div>

        <div class="lineBox">
          <el-form-item label="文种：" prop="wz">
            <el-input v-model="listQuery.wz" size="mini" placeholder="" style="width: 120px" />
          </el-form-item>
        </div>

        <div class="lineBox">
          <el-form-item label="题名：" prop="tm">
            <el-input v-model="listQuery.tm" size="mini" placeholder="" style="width: 120px" />
          </el-form-item>
        </div>

        <div class="lineBox">
          <el-form-item label="文件编号：" prop="wjbh">
            <el-input v-model="listQuery.wjbh" size="mini" placeholder="" style="width: 120px" />
          </el-form-item>
        </div>

        <div class="lineBox">
          <el-form-item label="主题词：" prop="ztc">
            <el-input v-model="listQuery.ztc" size="mini" placeholder="" style="width: 120px" />
          </el-form-item>
        </div>

        <div class="lineBox">
          <el-form-item label="文本：" prop="content">
            <el-input v-model="listQuery.content" size="mini" placeholder="" style="width: 120px" />
          </el-form-item>
        </div>

        <div class="lineBox">
          <el-form-item label="自动标审核" prop="audit_status">
            <el-select v-model="listQuery.audit_status" placeholder="审核状态" clearable="" style="width: 120px">
              <el-option label="已审核" value="1" />
              <el-option label="未审核" value="0" />
            </el-select>
          </el-form-item>
        </div>

        <div class="lineBox">
          <el-button size="mini" type="primary" @click="handleFilter">
            筛选
          </el-button>
          <!-- <el-button size="mini" type="primary" @click="qwjsFilter">
            全文检索
          </el-button> -->
          <el-button size="mini" @click="reset">
            重置
          </el-button>
        </div>
      </el-form>
    </div>

    <div class="myTable" style="min-height: 600px">
      <el-table :key="tableKey" :data="list" fit size="mini" highlight-current-row style="width: 100%">
        <el-table-column label="ID" prop="id" align="center" width="100" />
        <el-table-column label="档号" prop="dh" align="center" min-width="150" />
        <el-table-column label="密级" prop="mj" align="center" min-width="80" />
        <el-table-column label="题名" prop="tm" align="center" min-width="80" />
        <el-table-column label="文件编号" prop="wjbh" align="center" min-width="200" />

        <el-table-column label="年份" prop="lbh" align="center" min-width="50" />
        <el-table-column fixed="right" label="操作" align="center" min-width="200" class-name="small-padding fixed-width">
          <template slot-scope="{ row, $index }">
            <el-button type="primary" size="mini" @click="skip1(row, $index)">
              图谱
            </el-button>
            <el-button type="primary" size="mini" @click="skipdocview(row, $index)">
              查看
            </el-button>
          </template>
        </el-table-column>
      </el-table>
    </div>

    <div v-if="isText == false">
      <pagination size="mini" :page-sizes="[10]" :total="total" :page.sync="listQuery.page"
        :limit.sync="listQuery.limit" layout="total, sizes, prev, pager, next, jumper" @pagination="getList" />
    </div>
    <div v-if="isText == true">
      <pagination size="mini" :page-sizes="[10]" :total="total" :page.sync="listQuery.page"
        :limit.sync="listQuery.limit" layout="total, sizes, prev, pager, next, jumper" @pagination="getqwjs" />
    </div>
  </div>
</template>

<script>
import { artApi } from "@/api/art";
import Pagination from "@/components/Pagination"; // secondary package based on el-pagination

export default {
  components: { Pagination },

  data() {
    return {
      isText: false,
      formInline: {
        user: "",
        region: "",
      },
      value: "",

      tableKey: 0,
      list: [],
      total: 0,
      listLoading: false,
      listQuery: {
        mj: "",
        pageNumber: 1,
        page: 1,
        limit: 10,
        dh: "",
        qzh: "",
        jm: "",
        bgqx: "",
        lbh: "",
        sj: "",
        wz: "",
        tm: "",
        wjbh: "",
        ztc: "",
        content: "",
        audit_status: null,
      },
      data: [],
    };
  },

  mounted() { },

  created() {
    this.getList();
  },
  methods: {
    skipxiugai(row, index) {
      this.$router.push("/dashboard/eid?id=" + row.id);
    },

    // 修改跳转
    skip(row, index) {
      this.$router.push("/dashboard/save?id=" + row.id);
    },

    skipdocview(row, index) {
      this.$router.push("/dashboard/docview?id=" + row.id);
    },

    async skip1(row, index) {
      this.$router.push("/modelsknowledge/physical?dh=" + row.dh);
    },
    reset() {

      this.listQuery.mj = "";
      this.listQuery.dh = "";
      this.listQuery.qzh = "";
      this.listQuery.jm = "";
      this.listQuery.bgqx = "";
      this.listQuery.lbh = "";
      this.listQuery.sj = "";
      this.listQuery.wz = "";
      this.listQuery.tm = "";
      this.listQuery.wjbh = "";
      this.listQuery.ztc = "";
      this.listQuery.content = "";

      this.list = [];
      this.total = 0;
      this.isText = false;
      this.listQuery.page = 1;
      this.getList();

    },
    handleFilter() {
      this.list = [];
      this.total = 0;
      this.isText = false;
      this.listQuery.page = 1;
      this.getList();
    },

    qwjsFilter() {
      this.list = [];
      this.total = 0;
      this.isText = true;
      this.listQuery.page = 1;
      this.getqwjs();
    },

    async getqwjs() {
      this.list = [];
      this.listLoading = true;
      const response = await artApi("getDocumentQwjsPage", this.listQuery);
      if (response.code == 200) {
        this.list = response.data.resultList;
        this.total = response.totalCount;
        // this.type = response.type
        //   // Just to simulate the time of the request
        setTimeout(() => {
          this.listLoading = false;
        }, 1.5 * 1000);
      }
    },

    // 数据列表
    async getList() {
      this.list = [];
      this.listLoading = true;
      const response = await artApi("getDocumentPageSer", this.listQuery);
      if (response.code == 200) {
        this.list = response.data.resultList;
        this.total = response.totalCount;
        // this.type = response.type
        //   // Just to simulate the time of the request
        setTimeout(() => {
          this.listLoading = false;
        }, 1.5 * 1000);
      }
    },

    handleCreate() {
      this.$refs.addNoticeDlg.showDialog();
    },

    // 删除指标
    async handleDelete(row, index) {
      this.$confirm("此操作将永久删除该记录, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(async () => {
          const data = { id: row.id };

          const response = await artApi("deldelArticleById", data);

          if (response.code == 200) {
            this.$notify({
              title: "成功",
              message: response.message,
              type: "success",
              duration: 2000,
            });
            this.list.splice(index, 1);
          } else {
            this.$notify({
              title: "失败",
              message: response.message,
              type: "error",
              duration: 2000,
            });
          }
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除",
          });
        });
    },
  },
};
</script>

<style lang="scss" scoped>
::v-deep .el-checkbox__label {
  font-size: 12px;
}

.demo-image__preview {
  float: left;
  margin-left: 5px;
}
.demonstration {
  font-size: 12px;
  color: #333;
  font-weight: normal;
}
</style>
